﻿using System;
using System.Reflection;

namespace Inovout.Descriptors
{
    /// <summary>
    /// 用于描述枚举项的类
    /// </summary>
    public sealed class EnumItemDescriptor:FieldDescriptor
    {
        #region Private Field

        /// <summary>
        /// <summary>
        /// 枚举值
        /// </summary>
        private Enum value;

        public Type EnumType
        {
            get { return value.GetType(); }
        }

        #endregion

        #region Property

        /// <summary>
        /// 枚举值
        /// </summary>
        public Enum Value
        {
            get { return value; }
        }

        #endregion

        #region Constructor

        internal EnumItemDescriptor(FieldInfo enumFieldInfo)
            : base(enumFieldInfo)
        {
            this.value = (Enum)enumFieldInfo.GetValue(enumFieldInfo.FieldType);
        }

        #endregion

    }
}
